import collections


class FirstUnique(object):

    def __init__(self, nums):
        """
        :type nums: List[int]
        """
        self.st = set()
        self.a_ready = set()
        self.ans = collections.deque()
        for num in nums:
            if num not in self.a_ready and num not in self.st:
                self.ans.append(num)
                self.st.add(num)
            else:
                if num in self.st:
                    self.st.remove(num)
                    self.a_ready.add(num)

    def showFirstUnique(self):
        """
        :rtype: int
        """
        while self.ans and self.ans[0] in self.a_ready:
            self.ans.popleft()
        if self.ans:
            return self.ans[0]
        else:
            return -1

    def add(self, value):
        """
        :type value: int
        :rtype: None
        """
        if value not in self.a_ready and value not in self.st:
            self.ans.append(value)
            self.st.add(value)
        else:
            if value in self.st:
                self.st.remove(value)
                self.a_ready.add(value)
